// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   recovery_ok.java

package security.recovery;

import include.data_backup.MysqlStore;
import include.nseer_db.nseer_db_backup;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class recovery_ok extends HttpServlet
{

	public recovery_ok()
	{
	}

	public void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		HttpSession session = request.getSession();
		MysqlStore mysql = new MysqlStore();
		try
		{
			String database_group = "";
			nseer_db_backup mysql_db = new nseer_db_backup(dbApplication);
			if (mysql_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String sql1 = "show databases";
				for (ResultSet rs = mysql_db.executeQuery(sql1); rs.next();)
					database_group = (new StringBuilder(String.valueOf(database_group))).append(rs.getString("database")).append(",").toString();

				mysql_db.close();
				String str[] = {
					(String)dbSession.getAttribute("unit_db_name")
				};
				for (int i = 0; i < str.length; i++)
					if (database_group.indexOf(str[i]) != -1)
					{
						nseer_db_backup db = new nseer_db_backup(dbApplication);
						if (db.conn(str[i]))
						{
							String sql = (new StringBuilder("drop database ")).append(str[i]).toString();
							db.executeUpdate(sql);
						}
						db.close();
					}

				String file = (String)session.getAttribute("file");
				mysql.recovery(file);
				response.sendRedirect("security/recovery/recovery_ok_a.jsp");
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
